$(function (){

    $('#login').on('click', function (){
        const username = $('#username').val()
        const password = $('#password').val()

        if (!username || !password) {
            // alert('用户名或密码不能为空')

            layer.alert('用户名或密码不能为空', {icon: 2});
            return
        }
        $.post('http://localhost:8080/api/v1/admin/user/login', { username, password }, function (res) {
                console.log(res);
            if (res.code !== 200) {
                layer.msg(res.msg)
                return
            }
            layer.msg
            localStorage.setItem('token', res.token)
            location.href = 'index.html'
        })
    })




})